/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dahamschool.Connection;

import java.sql.DriverManager;
import java.sql.*;

/**
 *
 * @author LPK
 */
public final class ConnectionMysql {
    /*
     * These variable values are used to setup the ConnectionMysql object
     */
    static final String URL = "jdbc:mysql://localhost:3306/new_schema";
    static final String USER = "root";
    static final String PASSWORD = "future";
    static final String DRIVER = "com.mysql.jdbc.Driver";
    
    /*
     * This method is used to create a connection using the values listed above.
     * Notice the throws clause in the method signature. This allows the calling
     * method to deal with the exception rather than catching it in both places.
     * The ClassNotFoundException must be caught because the forName method
     * requires it.
     */
    public Connection getConnection() throws SQLException {
        Connection con = null;
        try {
            Class.forName(DRIVER);
            con =  DriverManager.getConnection(URL, USER, PASSWORD);
        } catch (ClassNotFoundException e) {
            System.out.println(e.getMessage());
            System.exit(-1);
        }
        return con;
    }
    /*
     * This method does most of the work. Note the try and catch. Virtually all
     * JDBC methods throw a SQLException that must be tended to. The ConnectionMysql
     * object is used to create a Statement object. The executeQuery method is
     * used to submit a SELECT SQL query. The executeUpdate method can be used
     * to delete, change, or insert records. The executeQuery method returns a
     * ResultSet object. It contains methods to navigate through the records in
     * the ResultSet object (the next method for example moves the cursor to the
     * next row; it returns false when it runs out of rows) as well as methods
     * to access fields in those rows. Notice that the id and job_id fields are
     * long data types while name and location are Strings. The ResultSet object
     * provides methods to deal with most common data types, but it&rsquo;s a
     * good idea to review how Java data types align with database data types.
     * The report is formatted using the format method introduced in Java 5.
     */
    
  
   
}
